package com.ddz.qpz.controller.api;

import com.ddz.common.result.BaseResult;
import com.ddz.qpz.pojo.entity.Fund;
import com.ddz.qpz.service.FundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: LiQingBo
 * @Date: 2021/10/28-10-28-9:53
 * @Description: com.ddz.qpz.controller.api
 * @version: 1.0
 */
@Api(tags = "基金接口")
@RestController
@RequestMapping("/api/core/fund")
@Slf4j
public class FundController {
    @Resource
    private FundService fundService;

    @ApiOperation("获取基金详细信息")
    @GetMapping("/show/{id}")
    public BaseResult show(@ApiParam(value = "基金id", required = true) @PathVariable("id") Long id) {
        Fund fund = fundService.getListById(id);
        return BaseResult.ok().data("fundDetail", fund);
    }

    @ApiOperation("基金列表")
    @GetMapping("list")
    public BaseResult list() {
        List<Fund> fundList = fundService.list();
        return BaseResult.ok().data("list", fundList).message("获取基金列表成功");
    }

}
